package com.example.shoppingdemo.RKL;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.shoppingdemo.R;
import com.example.shoppingdemo.RKL.Model.AmendModel;
import com.example.shoppingdemo.RKL.Model.MsgModel;
import com.example.shoppingdemo.RKL.Persenter.PersenterLoginAngSigin;

import java.util.List;

public class AmendActivity extends AppCompatActivity {
    private EditText phone,msg,password;
    private TextView h;
    private Button Amend;
    private PersenterLoginAngSigin persenterLoginAngSigin;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_amend);
        phone=findViewById(R.id.change_phone);
        msg=findViewById(R.id.amend_input);
        password=findViewById(R.id.change_password);
        h=findViewById(R.id.tu_msg);
        Amend=findViewById(R.id.btn_enroll);
        persenterLoginAngSigin=new PersenterLoginAngSigin();
        //修改密码方法
        Amend.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String Mphone = phone.getText().toString();
                String Mmsg = msg.getText().toString();
                String Mpassword = password.getText().toString();
                persenterLoginAngSigin.persenterAmend(Mphone, Mmsg, Mpassword, new PersenterLoginAngSigin.TransferAmend() {
                    @Override
                    public void TransferAmend(List<AmendModel> amendModelList) {
                        String s = amendModelList.get(0).getMmsg();
                        Toast.makeText(AmendActivity.this,Mmsg, Toast.LENGTH_SHORT).show();
                        if (TextUtils.isEmpty(s)){
                            Toast.makeText(AmendActivity.this,"密码重置失败", Toast.LENGTH_SHORT).show();
                        }
                        else {
                            Toast.makeText(AmendActivity.this, s, Toast.LENGTH_SHORT).show();
                        }
                    }
                });
            }
        });

        h.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String mphone = phone.getText().toString();
                persenterLoginAngSigin.persenterMsg(mphone, new PersenterLoginAngSigin.TransferMsg() {
                    @Override
                    public void TransferMsg(List<MsgModel> msgModelList) {
                        String s = msgModelList.get(0).getCode();
                        Toast.makeText(AmendActivity.this, s, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        });

    }



}